package com.zuxia.controller;


import com.zuxia.param.UserParam;
import com.zuxia.service.MemberService;
import com.zuxia.service.RoleMemberService;
import com.zuxia.utils.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 会员表 前端控制器
 * </p>
 *
 * @author laoli
 * @since 2024-11-17
 */
@RestController
@RequestMapping("/user")
public class MemberController {
    @Resource
    private MemberService memberService;

    @ApiOperation("用户密码登录接口")
    @PostMapping("/login/pwd")
    public R LoginPwd(@RequestBody UserParam userParam){
        return R.ok().message("登录成功").data("user-login-password",memberService.LoginPwd(userParam));
    }

    @ApiOperation("根据用户编号查询对应角色编号")
    @GetMapping("/login/phone/{phone}/{yzm}")
    public R getRoleMemberById(@PathVariable("phone") String phone,@PathVariable("yzm") String yzm) throws Exception{
        return R.ok().message("登陆成功").data("user-login-phone", memberService.LoginPhone(phone,yzm));
    }

    @ApiOperation("用户验证码发送的接口")
    @GetMapping("/yzm/{phone}")
    public R yzm(@PathVariable("phone") String phone) throws Exception{
        return R.ok().message("验证码已发送").data("user-send-yzm",memberService.sendYZM(phone));
    }
}

